Imports System
Imports System.Data
Imports System.Configuration
Imports System.Data.SqlClient
Public Class MyCodeBehind
    Inherits System.Web.UI.Page
    Protected WithEvents lstUsers As System.Web.UI.WebControls.DropDownList

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not Page.IsPostBack Then
            Dim myConn As SqlConnection
            Dim myCom As SqlCommand
            Dim myDrd As SqlDataReader
            Dim strSQL = "select * from tblUsers "
            strSQL += "order by UserName ASC"
            myConn = New SqlConnection(ConfigurationSettings.AppSettings("cons"))
            myConn.Open()
            myCom = New SqlCommand(strSQL, myConn)
            myDrd = myCom.ExecuteReader()
            lstUsers.DataSource = myDrd
            lstUsers.DataBind()
            myConn.Close()
        End If

    End Sub

End Class
